
const Hotel = require('./Hotel')
const Search = require('./Search')
const Rate = require('./Rate')
const Budget = require('./Budget')

class AppHotel {
  constructor () {
    this.hotels = []
    this.searchEngine = new Search()
    this.budgets = new Budget()
  }

  createRate (regular, loyalty, regularWeekend, loyaltyWeekend) {
    const rate = new Rate()
    rate.setPriceWeek(regular, loyalty)
    rate.setPriceWeekend(regularWeekend, loyaltyWeekend)
    return rate
  }

  registerHotels () {
    const rate = this.createRate(110, 80, 90, 80)
    this.registerHotel('Lakewood', 3, rate)
    const rate1 = this.createRate(160, 110, 60, 50)
    this.registerHotel('Bridgewood', 4, rate1)
    const rate2 = this.createRate(220, 100, 150, 40)
    this.registerHotel('Ridgewood', 5, rate2)
  }

  registerHotel (name, rating, rate) {
    const hotel = new Hotel(name, rating, rate)
    this.hotels.push(hotel)
  }

  searchHotelLowerPrice (budget) {
    return this.searchEngine.searchHotelLowerPrice(budget)
  }

  createBudgets (hoteis, stay) {
    return this.budgets.createBudgets(hoteis, stay)
  }

  setStay (stay) {
    this.stay = stay
  }

  setBudgets (budgets) {
    this.budgets = budgets
  }

  getBudgets () {
    return this.budgets
  }

  getHotels () {
    return this.hotels
  }

  getStay () {
    return this.stay
  }
}

module.exports = AppHotel
